import InputManager from "./InputManager";
import TipPanel from "../UI/TipPanel";
import SpriteManager from "./SpriteManager";
import GameManager from "./GameManager";
import LoadingPanel from "../UI/LoadingPanel";
import StartPanel from "../UI/StartPanel";
import SettingPanel from "../UI/SettingPanel";
import GamePlayPanel from "../UI/GamePlayPanel";
import WinLosePanel from "../UI/WinLosePanel";
import ResurrectionPanel from "../UI/ResurrectionPanel";
import Cell from "../Core/Cell";
import CellFunctions from "../Core/CellFunctions";

const {ccclass, property} = cc._decorator;

@ccclass
export default class UIManager extends cc.Component {
    public static Instance:UIManager;

    @property(cc.WXSubContextView)
    wxSubContextView:cc.WXSubContextView = null;

    @property(cc.Button)
    Button_L:cc.Button = null;

    @property(cc.Button)
    Button_M:cc.Button = null;

    @property(cc.Button)
    Button_R:cc.Button = null;

    onLoad () {
        UIManager.Instance = this;
    }

    start () {
        for (let index = 0; index < this.node.childrenCount; index++) {
            let child = this.node.children[index];
            let active:boolean = child.active;
            child.active = true;
            child.active = active;
        }
        
        this.Button_L.node.on('click', ()=>{
            CellFunctions.MoveLefOrRight(-1);
        }, this);
        this.Button_R.node.on('click', ()=>{
            CellFunctions.MoveLefOrRight(+1);
        }, this);
        this.Button_M.node.on('click', ()=>{
            CellFunctions.MoveDownAllCell();
        }, this);
    }
}
